package com.teamit.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.teamit.entity.Employee;
import com.teamit.entity.Project;
import com.teamit.service.EmployeeService;

public class JsonServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		EmployeeService es=new EmployeeService();
		Project project=(Project) request.getSession().getAttribute("project");
		List<Employee> list=es.findByProject(project.getId());
		response.setContentType("application/json;charset=UTF-8");
		PrintWriter out = response.getWriter();
		Gson gson=new Gson();
		String json=gson.toJson(list);
		out.print(json);
		out.flush();
		out.close();
	}

}
